//
//  MMSqliteModelTool.h
//  sqlite封装
//
//  Created by lianglibao on 2018/1/15.
//  Copyright © 2018年 梁立保. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "MMModelProtocol.h"

@interface MMSqliteModelTool : NSObject

/// 根据类名&uid创建数据库表
/// @param cls 类对象
/// @param uid 用户id
/// @param successBlock 是否成功回调,一定在主线程回调
+ (void)createTable:(Class)cls
                uid:(NSString *)uid
       successBlock:(void(^)(BOOL isSuccess))successBlock;

/// 根据类名&uid评估是否需要更新数据库表
/// @param cls 类对象
/// @param uid 用户id
/// @param successBlock 是否需要更新回调,一定在主线程回调
+ (void)isTableRequiredUpdate:(Class)cls
                          uid:(NSString *)uid
                 successBlock:(void(^)(BOOL isSuccess))successBlock;

/// 根据类名&uid更新数据库表
/// @param cls 类对象
/// @param uid 用户id
/// @param successBlock 更新是否成功回调,一定在主线程回调
+ (void)updateTable:(Class)cls
                uid:(NSString *)uid
       successBlock:(void(^)(BOOL isSuccess))successBlock;

/// 根据数据模型&uid保存到数据库
/// @param model 保存的数据模型
/// @param uid 用户id
/// @param successBlock 保存是否成功,一定在主线程回调
+ (void)saveModel:(id)model
          withuid:(NSString *)uid
     successBlock:(void(^)(BOOL isSuccess))successBlock;

/// 根据数据模型&uid删除数据库数据
/// @param model 需要删除的数据库数据
/// @param uid 用户id
/// @param successBlock 是否删除成功,一定在主线程回调
+ (void)deleteModel:(id)model
            withuid:(NSString *)uid
       successBlock:(void(^)(BOOL isSuccess))successBlock;

/// 根据类名&uid&字段名&字段值删除指定数据库表中的字段数据
/// @param modelClass 类对象
/// @param column 字段名
/// @param value 字段值
/// @param uid 用户id
/// @param successBlock 是否成功删除,一定在主线程回调
+ (void)deleteModels:(Class)modelClass
     whereColumnName:(NSString *)column
             isValue:(id)value
             withuid:(NSString *)uid
        successBlock:(void(^)(BOOL isSuccess))successBlock;

/// 根据类名&uid&自定义条件语句删除数据库数据
/// @param modelClass 类对象
/// @param whereSQL 自定义条件语句
/// @param uid 用户id
/// @param successBlock 是否删除成功,一定在主线程回调
+ (void)deleteModels:(Class)modelClass
       withCondition:(NSString *)whereSQL
             withuid:(NSString *)uid
        successBlock:(void(^)(BOOL isSuccess))successBlock;

@end
